package org.primefaces.examples.moviecollector.dao;


import static org.junit.Assert.*;

import java.util.List;


import org.junit.Test;
import org.junit.runner.RunWith;
import org.primefaces.examples.moviecollector.domain.Calificacion;
import org.primefaces.examples.moviecollector.domain.Comentrarios;
import org.primefaces.examples.moviecollector.domain.Eventos;
import org.primefaces.examples.moviecollector.domain.Usuarios;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration;
import org.springframework.transaction.annotation.Transactional;



@RunWith(SpringJUnit4ClassRunner.class)
@Transactional
@TransactionConfiguration(transactionManager = "txManager")
@ContextConfiguration(locations = { "/applicationContext.xml" })


public class ComentariosDAOWithJPATest {
	
	
private ComentariosDAO cometDAO;
	
	@Autowired
	public void setRepository(ComentariosDAO cometDAO){
		this.cometDAO=cometDAO;
	}
	
	@Test
	public void guardarCalificacion(){
		Comentrarios comet = new Comentrarios();
		comet.setComentarios("Nuy Bakano");
		
		cometDAO.persist(comet);
		assertNotNull(comet.getId());
	}
	

	@Test
	public void eliminar(){
	
		Comentrarios comet = new Comentrarios();
		comet.setComentarios("Chevere");
	
		cometDAO.persist(comet);
		
		cometDAO.delete(comet);
		
		
		assertFalse((!comet.getComentarios().equals("Chevere")));
		
		
	}
}

